home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 684 / 684.xpi / chrome / fireftp.jar / content / js / etc / loadUnload.js < prev    next >
Text File  |  2008-07-11  |  6KB  |  142 lines

  1. function startup() {
  2.   if (gStrbundle) {                            // we get two onload events b/c of the embedded browser
  3.     return;
  4.   }
  5.  
  6.   window.onerror         = detailedError;
  7.  
  8.   gStrbundle             = $("strings");
  9.   gConnectButton         = $('connectbutton');
  10.   gAccountField          = $('account');
  11.   gFolderField           = $('folder');
  12.   gLocalPath             = $('localpath');
  13.   gLocalTree             = $('localtree');
  14.   gLocalDirTree          = $('localdirtree');
  15.   gLocalTreeChildren     = $('localtreechildren');
  16.   gLocalDirTreeChildren  = $('localdirtreechildren');
  17.   gRemotePath            = $('remotepath');
  18.   gRemoteTree            = $('remotetree');
  19.   gRemoteDirTree         = $('remotedirtree');
  20.   gRemoteTreeChildren    = $('remotetreechildren');
  21.   gRemoteDirTreeChildren = $('remotedirtreechildren');
  22.   gCmdlogDoc             = $('cmdlog').contentWindow.document;
  23.   gCmdlogBody            = $('cmdlog').contentWindow.document.body;
  24.   gQueueTree             = $('queuetree');
  25.   gQueueTreeChildren     = $('queuetreechildren');
  26.   gStatusBytes           = $('statusbytes');
  27.   gStatusElapsed         = $('statuselapsed');
  28.   gStatusRemaining       = $('statusremaining');
  29.   gStatusRate            = $('statusrate');
  30.   gStatusMeter           = $('statusmeter');
  31.   gLocalTree.view        = localTree;
  32.   gLocalDirTree.view     = localDirTree;
  33.   gRemoteTree.view       = remoteTree;
  34.   gRemoteDirTree.view    = remoteDirTree;
  35.   gQueueTree.view        = queueTree;
  36.  
  37.   gProfileDir            = Components.classes["@mozilla.org/file/directory_service;1"].createInstance(Components.interfaces.nsIProperties)
  38.                                      .get("ProfD", Components.interfaces.nsILocalFile);
  39.   gAtomService           = Components.classes["@mozilla.org/atom-service;1"].getService            (Components.interfaces.nsIAtomService);
  40.   gLoginManager          = Components.classes["@mozilla.org/login-manager;1"].getService           (Components.interfaces.nsILoginManager);
  41.   gIos                   = Components.classes["@mozilla.org/network/io-service;1"].getService      (Components.interfaces.nsIIOService);
  42.   gPromptService         = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  43.   gPrefsService          = Components.classes["@mozilla.org/preferences-service;1"].getService     (Components.interfaces.nsIPrefService);
  44.   gFireFTPUtils          = Components.classes['@nightlight.ws/fireftputils;1'].getService          (Components.interfaces.nsIFireFTPUtils);
  45.   gFormHistory           = Components.classes["@mozilla.org/satchel/form-history;1"].getService    (Components.interfaces.nsIFormHistory ?
  46.                                                                                                     Components.interfaces.nsIFormHistory :
  47.                                                                                                     Components.interfaces.nsIFormHistory2);
  48.   gLoginInfo             = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",     Components.interfaces.nsILoginInfo, "init");
  49.  
  50.   gPrefs                 = gPrefsService.getBranch("fireftp.");
  51.   gPlatform              = getPlatform();
  52.  
  53.   if (gPrefsService instanceof Components.interfaces.nsIPrefBranchInternal) {
  54.     gPrefsService.addObserver("fireftp", prefsObserver, false);
  55.   }
  56.  
  57.   gMaxCon                = gPrefs.getIntPref("concurrentmax");
  58.  
  59.   gConnections           = new Array();
  60.   for (var x = 0; x < gMaxCon; ++x) {
  61.     gConnections.push(new ftpMozilla(x ? new transferObserver(x + 1) : ftpObserver));
  62.     gConnections[x].type            = x ? 'transfer' : '';
  63.     gConnections[x].connNo          = x + 1;
  64.     gConnections[x].errorConnectStr = gStrbundle.getString("errorConn");
  65.     gConnections[x].errorXCheckFail = gStrbundle.getString("errorXCheckFail");
  66.     gConnections[x].passNotShown    = gStrbundle.getString("passNotShown");
  67.     gConnections[x].l10nMonths      = gStrbundle.getString("months").split("|");
  68.   }
  69.  
  70.   gFtp                   = gConnections[0];
  71.   gFtp.setSecurity("");
  72.  
  73.   gTransferTypes         = new Array(gStrbundle.getString("auto"), gStrbundle.getString("binary"), gStrbundle.getString("ascii"));
  74.   gMonths                = gStrbundle.getString("months").split("|");
  75.  
  76.   treeHighlighter.valid  = new Array({ tree: gLocalTree,  children: gLocalTreeChildren,  column: "localname"  },
  77.                                      { tree: gRemoteTree, children: gRemoteTreeChildren, column: "remotename" },
  78.                                      { tree: gQueueTree,  children: gQueueTreeChildren });
  79.  
  80.   if ($('searchWhich').selectedIndex == -1) {
  81.     $('searchWhich').selectedIndex = 0;
  82.   }
  83.  
  84.   searchSelectType();
  85.   showSearchDates();
  86.   securityPopup();
  87.  
  88.   readPreferences(true);
  89.   setConnectButton(true);
  90.   accountButtonsDisabler(true);
  91.   connectedButtonsDisabler();
  92.   localDirTree.changeDir(gLocalPath.value);
  93.   loadSiteManager(true);
  94.   loadPrograms();
  95.  
  96.   var trht = 'http://www.trht.net/fireftp';
  97.   appendLog("<span id='opening' style='line-height:16px'><span style='cursor:pointer;text-decoration:underline;color:blue;' onclick=\"window.open('http://fireftp.mozdev.org/donate.html','FireFTP');\">"
  98.       + "FireFTP</span> <span>" + gVersion
  99.       + "  '</span><span style='cursor:pointer;text-decoration:underline;' onclick=\"window.open('" + trht + "','trht');\">"
  100.       + "Human Being</span>'"
  101.       + " <img style='cursor:pointer;text-decoration:underline;' onclick=\"window.open('"
  102.       + trht + "','trht');\" src='chrome://fireftp/skin/icons/trht.png'/>"
  103.       + " " + gStrbundle.getString("opening")
  104.       + "</span><br style='font-size:5pt'/><br style='font-size:5pt'/>", 'blue', "info");
  105.   gCmdlogBody.scrollTop = 0;
  106.  
  107.   onAccountChange(gDefaultAccount);
  108.   setTimeout("gAccountField.focus()", 0);
  109.  
  110.   tipJar();
  111.  
  112.   setTimeout(doResizeHack, 0);
  113.  
  114.   if (gLoadUrl) {
  115.     setTimeout("externalLink()", 1000);
  116.   }
  117. }
  118.  
  119. function beforeUnload() {
  120.   return "";
  121. }
  122.  
  123. function unload() {
  124.   if (gPrefsService instanceof Components.interfaces.nsIPrefBranchInternal) {
  125.     gPrefsService.removeObserver("fireftp", prefsObserver, false);
  126.   }
  127.  
  128.   for (var x = 0; x < gMaxCon; ++x) {
  129.     if (gConnections[x].isConnected) {
  130.       gConnections[x].disconnect();
  131.     }
  132.   }
  133.  
  134.   if (gFxp && gFxp.isConnected) {
  135.     gFxp.disconnect();
  136.   }
  137.  
  138.   for (var x = 0; x < gTempEditFiles.length; ++x) {
  139.     gFireFTPUtils.removeFile(gTempEditFiles[x].file);
  140.   }
  141. }
  142.